#define  _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    int numOfSubarrays(vector<int>& arr, int k, int threshold) {
        int tgt = k * threshold;
        int sum = 0;
        int i = 0;
        for (; i < k; i++)
        {
            sum += arr[i];
        }

        int ret = 0;
        if (sum >= tgt) ret++;

        int n = arr.size();
        for (; i < n; i++)
        {
            sum -= arr[i - k];
            sum += arr[i];
            if (sum >= tgt) ret++;
        }

        return ret;
    }
};